import { getWxWorkJsApiConfig } from "@/api/sys";

export default {
    state: {
        jsapiTicket: {}
    },
    getters: {},
    mutations: {
        setJsapiTicket(store, ticket) {
            store.jsapiTicket = ticket;
        }
    },
    actions: {
        getWxWorkJsApiConfig({ commit }, payload) {
            return new Promise((resolve, reject) => {
                getWxWorkJsApiConfig(payload)
                    .then(res => {
                        if (res && res.data) {
                            commit("setJsapiTicket", res.data);
                            resolve(res.data);
                        } else {
                            reject(res);
                        }
                    })
                    .catch(err => {
                        reject(err);
                    });
            });
        }
    },
    namespaced: true
};
